﻿<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <!--[if lt IE 9]>
<script type="text/javascript" src="../lib/html5.js"></script>
<script type="text/javascript" src="../lib/respond.min.js"></script>
<script type="text/javascript" src="../lib/PIE_IE678.js"></script>
<![endif]-->
    <link href="../css/H-ui.min.css" rel="stylesheet" type="text/css" />
    <link href="../css/H-ui.admin.css" rel="stylesheet" type="text/css" />
    <link href="../lib/Hui-iconfont/1.0.1/iconfont.css" rel="stylesheet" type="text/css" />
    <!--[if IE 6]>
<script type="text/javascript" src="../lib/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->
    <title>库存管理</title>
    <style type="text/css">
        td.details-control {
            background: url('../lib/Hui-iconfont/details_open.png') no-repeat center center;
            cursor: pointer;
        }

        tr.shown td.details-control {
            background: url('../lib/Hui-iconfont/details_close.png') no-repeat center center;
        }
    </style>
</head>
<body>
    <div class="pd-5">
        <div class="text-c" id="findfdiv">
             <span class="select-box" style="width: 200px;">
                <select class="select" size="1" name="find仓库ID" id="find仓库ID"></select>
            </span>
            <input type="text" class="input-text" style="width: 250px" placeholder="输入名称" id="find物品名称" name="find物品名称">
            <button onclick="findreolad()" class="btn btn-success radius" id="" name=""><i class="Hui-iconfont">&#xe665;</i> 查询</button>
        </div>
        <div class="cl pd-5 bg-1 bk-gray mt-5">
            <span class="l">
                <a href="javascript:;" onclick="showlist()" class="btn btn-danger radius"><i class="Hui-iconfont">&#xe687;</i> 查看明细</a>
                </span>
            <span class="r"><strong></strong> </span>
        </div>
        <div class="mt-5 ml-20">
            <table class="table table-border table-bordered table-striped table-hover" id="tablelist" width="100%">
                <thead>
                    <tr class="text-c">
                        <th width="30">详细</th>
                        <th>仓库名称</th>
                        <th>主分类</th>
                        <th>名称编号</th>
                        <th>库存数量</th>
                        <th>单位</th>
                    </tr>
                </thead>
                <tbody>
                </tbody>
            </table>

        </div>
    </div>
    <script src="../hcjsui/Scripts/jquery-1.9.1.min.js" type="text/javascript"></script>
    <script type="text/javascript" src="../lib/layer/1.9.3/layer.js"></script>
    <script type="text/javascript" src="../lib/laypage/1.2/laypage.js"></script>
    <script type="text/javascript" src="../lib/My97DatePicker/WdatePicker.js"></script>
    <script type="text/javascript" src="../lib/datatables/1.10.0/jtable.js"></script>
    <script src="../hcjsui/js/_Define.js" type="text/javascript"></script>
    <script type="text/javascript" src="../js/hcui.js"></script>
    <script type="text/javascript" src="../js/hcui_list.js"></script>
    <script type="text/javascript">
        hcapigetNoError("../api/Task/GetStoreTask", {}, function (backdata) {
        });
        tablelistSelectType = 0;
        $(function () {
            spsetBaseNoBt("view_erp_store", "id", "view_erp_store as T", "*", "#tablelist", "StoreManage", "库存", "StoreManage");
            hcdoselbyPost("id,name", "herp_storehouse", "databranchid='" + HCUser.HCUorg + "'", "", "", "id", function (data) {
                SetSelectWithArrayIdName("#find仓库ID", data);
            });

            hcmtable = $("#tablelist").DataTable({
                "serverSide": true,//服务端处理分页 无法使用当前查找
                "bFilter": false,  //是否使用内置的过滤功能
                "bInfo": true, "fnDrawCallback": function () { dTappendSkipPage(); },
                "bLengthChange": false, //改变每页显示数据数量
                "ajax": {
                    "type": "POST",
                    "url": spselUrl(" and databranchid=" + HCUser.HCUorg + " and 库存数量>0 and 物品编号 is not null "),
                    "data": function (d) {
                        $("#findfdiv").find("input[type='text']").each(function () {
                            d[this.id] = $(this).val();
                        });
                        $("#findfdiv").find("select").each(function () {
                            d[this.id] = $(this).val();
                        });
                    }
                },
                "order": [[1, "asc"]],//默认第几个排序
                aLengthMenu: [10, 20, 50],
                "columns": [
                     {
                         "class": 'details-control',
                         "orderable": false,
                         "data": null,
                         "defaultContent": ''
                     }, { "data": "仓库名称" }, { "data": "物品主分类" }, { "data": "物品编号" }, { "data": "库存数量" }, { "data": "物品规格" }
                ],
                "createdRow": function (row, data, index) {
                    if ((data.库存数量 * 1) < (data.warningcount * 1)) {
                        $('td', row).eq(0).css('backgroundColor', 'red');
                        //$('td', row).eq(2).css('backgroundColor', '#99FFCC');
                        //$('td', row).eq(5).css('backgroundColor', '#FFCCFF');
                        //$('td', row).eq(3).css('color','#fff');
                    }
                },
                "columnDefs": [
                   //// 操作列
                   // {
                   //     "targets": [6],
                   //     "render": function (data, type, row) {
                   //         return "<a style=\"text-decoration:none\" class=\"ml-5\" onClick=\"toolUpdateById('" + data + "')\" href=\"javascript:;\" title=\"编辑\"><i class=\"Hui-iconfont\">&#xe6df;编辑</i></a> " +
                   //                "<a style=\"text-decoration:none\" class=\"ml-5\" onClick=\"toolDelete('" + data + "')\"     href=\"javascript:;\" title=\"删除\"><i class=\"Hui-iconfont\">&#xe6e2;删除</i></a>";
                   //         //"<a style=\"text-decoration:none\" onClick=\"toolUpdateById(" + data + ")\" href=\"javascript:;\" title=\"审核\">审核</a>" +
                   //     }
                   // },
                    {
                        "targets": [5],
                        "render": function (data, type, row) {
                            return row.物品规格 + "【" + row.物品单位 + "】";
                        }
                    },
                    //不排序
                   {
                       "orderable": false,
                       "targets": [0, 5]
                   }

                ]
            });


            $('#tablelist tbody').on('click', 'td.details-control', function () {
                var tr = $(this).closest('tr');
                var row = hcmtable.row(tr);
                if (row.child.isShown()) {
                    // This row is already open - close it
                    row.child.hide();
                    tr.removeClass('shown');
                }
                else {
                    // Open this row
                    row.child(format(row.data())).show();
                    tr.addClass('shown');
                }
            });



        });
        function showlist()
        {
            var index = layer.open({
                type: 2,
                title: "出入库明细",
                content: "StoreInOutLogList.html"
            });
            layer.full(index);
        }
        function format(d) {
            return '<table cellpadding="5" cellspacing="0" border="0" style="padding-left:50px;">' +
                '<tr>' +
                    '<td>库存预警数:</td>' +
                    '<td>' + d.warningcount + '</td>' +
                '</tr>' +
                '<tr>' +
                    '<td>仓库联系人:</td>' +
                    '<td>' + d.仓库联系人 + '</td>' +
                '</tr>' +
                '<tr>' +
                    '<td>仓库联系方式:</td>' +
                    '<td>' + d.仓库联系方式 + '</td>' +
                '</tr>' +
            '</table>';
        }

    </script>
</body>
</html>
